home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / POLYGONS.TXT < prev    next >
Text File  |  1996-07-04  |  4KB  |  57 lines

  1.     ┌──────────────────────────╖                        PowerBASIC v3.20
  2.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  3.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  4.  │  │ FILE NAME   POLYGONS.TXT ║          by          ╘════════════════─ ║ ║
  5.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  6.  │  ╘══════════════════════════╝                                         ║ ║
  7.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  8.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  9.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  10.  │ as long as this code is not distributed in any compilable format.     ║ ║
  11.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  12.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  13.    │                ....................................                   ║
  14.    ╘═══════════════════════════════════════════════════════════════════════╝
  15.  
  16.   Here is a set of routines that will either  allow you to compute the
  17. required points of a polygon or draw the object complete. In fact, the
  18. use of the word polygon may not be totally correct as there is a star,
  19. a circle, an arc, and a 3-D oval routine included! Most of these items
  20. are geometrically complicated and require several variables. A TYPE is
  21. used pass all the many variables into  and around the routines and the
  22. PUBLIC variable pPi# is required.  You'll have to become familiar with
  23. PolygonTYPE  and how it is used to traverse these waters but no worry!
  24.  
  25.   The logic used in these routines is plane geometry and a bit past my
  26. kin, but all the figures are based on one or two circles. The star and
  27. the 3-D polygon both use two circles to get things drawn.  There are a
  28. few restrictions on the 3-D routine due to it's logic and some natural
  29. blocks to all of them due to the composition of the universe we happen
  30. to be stuck in!  The routines are not CAD quality and are not meant to
  31. be but they get real useful every now and again and are very fast! The
  32. best part is that the figures can be drawn using XORed logic! And that
  33. brings us to PlotCircle.  By no means is this a replacement for CIRCLE
  34. as it really doesn't do as good a job and is slower than dirt,  BUT it
  35. can be XORed on and off! This makes it possible to use a dotted circle
  36. until the correct position is found then use CIRCLE to do the finished
  37. product.
  38.  
  39.   Once you have set the values for the members of PolygonTYPE you need
  40. to call PolygonReady so the last four members can be computed.  Repeat
  41. this if you change t.Radius,  t.Aspect, t.Points, and/or t.Start.  Any
  42. changes here  will result in changes to at least  one of the last four
  43. members also. Once you've got all this done you may compute all points
  44. or any one point by calling PolygonPoints or PolygonPoint.  To capture
  45. all the points you will require an INTEGER ARRAY XYs%(0:1,0:t.Points).
  46. Elements 0,0 and 0,1 are loaded with the same values as the last point
  47. so the last side of the polygon can be drawn. The last item to take in
  48. to account is when you are drawing a 3-D figure or a STAR.  The second
  49. TYPE for the back or inside does not always follow all the rules!  You
  50. will want to pay particular attention to the screens for each of these
  51. figures in regards to the different values.
  52.  
  53.   However you use these routines I am sure that you will find them not
  54. only productive but also fun!  They are fast enough to create animated
  55. sequences such as spinning stars, moving boxes, etc. This makes them a
  56. favorite for preschooler games and educational demonstrations.
  57.